import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'dart:convert';
import 'package:shared_preferences/shared_preferences.dart';

import 'Index.dart';
class EndPage extends StatefulWidget {
  @override
  _EndPageState createState() => _EndPageState();
}

class _EndPageState extends State<EndPage> {
  String qrCode;
  Uint8List bytes;
  String qrNumber;


  void initState() {
    super.initState();
    getCompanyId();
    setState(() {
      qrNumber:'123';
    });
  }

  getCompanyId() async {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    var qrCode = prefs.getString('qrCode');
    var qrN = prefs.getString('qrNumber');
    print(qrN);
    setState(() {
      qrNumber:qrN;
      qrCode = qrCode;
      bytes = Base64Decoder().convert(qrCode);

    });
  }

  @override
  Widget build(BuildContext context) {
    Map weight = ModalRoute.of(context).settings.arguments;
    return Scaffold(
      appBar: AppBar(
        actions: <Widget>[
          IconButton(
              icon: Icon(Icons.home),
              onPressed: () {
                Navigator.of(context).push(MaterialPageRoute(
                  builder: (BuildContext context) {
                    return Index();
                  },
                  fullscreenDialog: true,
                ));
              })
        ],
      ),

      body: (
          Column(
            children: <Widget>[
              Center(
                child: bytes!=null ? Image.memory(bytes,fit: BoxFit.contain,):Container(),
              ),
              Center(
                child: Text('${weight['qrNumber']}'),
              )
            ],
          )


      ),
    );
  }
}
